//最长子序列  贪心
let arr = [3, 7, 11, 15, 9, 11, 12];
let arr2 = [3, 7, 22, 4, 8, 13, 9, 11, 12];
const func = (arr) => {
  let newarr = [];
  if (!newarr.length) {
    newarr.push(arr[0]);
  }
  for (let i = 0; i < arr.length; i++) {
    if (newarr[newarr.length - 1] < arr[i]) {
      newarr.push(arr[i]);
    } else {
      for (let j = 0; j < newarr.length; j++) {
        if (arr[i] > newarr[j] && arr[i] < newarr[j + 1]) {
          newarr[j + 1] = arr[i];
        }
      }
    }
  }
  console.log(newarr);
};
func(arr2);
